<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 1 - 定义一个数组，控制台中打印出大于5的数字。
    <script>
        var arr= [1,9,33,22,4,2,7]
        var newArr = []
        var j = 0 
        for (var i = 0; i < arr.length; i++){
            if(arr[i] > 5){
                newArr[j] = arr[i];
                j++
            }
        }
        console.log(newArr);
    </script> -->

<!-- 2 - 求数组的最大值和最小值
<script>
    var arr= [-1,9,33,22,4,-3,7]
    var max = arr[0]
    var mix = arr[0]
    for (var i = 0; i < arr.length; i++){
        if (arr[i] > max){
            max = arr[i]
        }else if(arr[i] < mix){
            mix = arr[i]
        }
    }
    console.log('数组的最大值:' + max , '数组的最小值:' + mix);
</script> -->

<!-- 3 - 将数组中数字内容求和
    <script>
        var arr = [12,34,2,5,76];
        var sum = 0
        for (var i = 0 ; i < arr.length ; i++){
            sum = sum + arr[i]
        }
        console.log(sum);
    </script> -->

<!-- 4 -要求将数组中的0项去掉，将不为0的值存入一个新的数组，生成新的数组
    <script>
        var arr = [4, 0, 7, 9, 0, 0, 2, 6, 0, 3, 1, 0];
        var newArr = []
        var j = 0
        for (var i = 0 ; i < arr.length ; i++){
            if (arr[i] != 0){
                newArr[j] = arr[i] ;
                j++
            }
        }
        console.log(newArr);
    </script> -->

<!-- 5 -  倒序遍历数组
<script>
    var arr= [1,9,33,22,4,2,7] 
    var newArr = []
    var num = arr.length
    for (var i=0; i<=arr.length;i++){
        newArr[i] = arr[num-i]
    }
    console.log(newArr);
</script> -->


</body>
</html>